<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">

	<ui:composition>

		<c:set var="accionListenerNuevo" value="nuevoEvent" />
		<c:set var="accionListenerModificar" value="modificarEvent" />
		<c:set var="accionListenerEliminar" value="eliminarEvent" />
		<c:set var="accionAplicar" value="aplicarAction" />
		<c:set var="AccionCancelar" value="cancelarAction" />
		<c:set var="botonNuevo" value="botonNuevo" />

		<c:set var="botonModificar" value="botonModificar" />
		<c:set var="botonEliminar" value="botonEliminar" />
		<c:set var="botonAplicar" value="botonAplicar" />
		<c:set var="botonCancelar" value="botonCancelar" />
		<c:set var="accionSeleccionada" value="accionSeleccionada" />

		<c:set var="aplicarFiltroEvent" value="AplicarFiltroEvent" />
		


		<c:set var="panelFiltroVisible" value="panelFiltroVisible" />
		<c:set var="filtroPanelHtml" value="filtroPanel" />


		<rich:effect name="ocultarFiltro" for="filtroPanel" type="Fade" />
		<rich:effect name="mostrarFiltro" for="filtroPanel" type="Appear" />

		<t:saveState id="accionSeleccionada"
			value="#{backingBean[accionSeleccionada]}" />
		<a4j:region>
			<rich:toolBar height="20" id="tb" width="100%" itemSeparator="grid">

				<rich:toolBarGroup id="tbg" location="left">
					<a4j:commandButton id="nuevoButton" title="Ingresar nuevo elemento"
						binding="#{backingBean[botonNuevo]}"
						image="/imagenes/document.png"
						reRender="buscarButton,modificarButton,eliminarButton,tbg,tb,accionSeleccionadaLabel"
						actionListener="#{backingBean[accionListenerNuevo]}" />

					<a4j:commandButton id="buscarButton" immediate="true"
						onclick="mostrarFiltro()" title="Buscar un elemento"
						image="/imagenes/ico_buscar.gif"
						style="width : 13px; height : 15px;" />

					<a4j:commandButton id="eliminarButton"
						binding="#{backingBean[botonEliminar]}"
						reRender="buscarButton,modificarButton,eliminarButton,tbg,tb,accionSeleccionadaLabel"
						title="Eliminar elemento" image="/imagenes/delete_edit.gif"
						actionListener="#{backingBean[accionListenerEliminar]}" />

					<a4j:commandButton id="modificarButton"
						binding="#{backingBean[botonModificar]}"
						reRender="buscarButton,modificarButton,eliminarButton,tbg,tb,accionSeleccionadaLabel"
						title="Modificar elemento" image="/imagenes/launch_restart.gif"
						actionListener="#{backingBean[accionListenerModificar]}" />
				</rich:toolBarGroup>

				<rich:toolBarGroup location="right">
					<h:commandButton id="aplicarButton"
						binding="#{backingBean[botonAplicar]}" title="Aplicar cambios"
						type="submit" image="/imagenes/ok.gif"
						action="#{backingBean[accionAplicar]}" />
					<h:commandButton id="cancelButton" title="Cancelar cambios"
						image="/imagenes/error.gif" immediate="true"
						binding="#{backingBean[botonCancelar]}"
						action="#{backingBean[accionCancelar]}" />
					<a4j:commandButton id="limpiarButton" title="Limpiar formularios"
						immediate="true" onclick="document.form1.reset()"
						image="/imagenes/delete.gif" />
				</rich:toolBarGroup>
			</rich:toolBar>

			<table width="100%"> <tr> <td align="right"> <h:outputLabel
				id="accionSeleccionadaLabel"
				value="Acción seleccionada: #{backingBean[accionSeleccionada]}"
				style="text-align: right; width: 100%;" /> </td> </tr> </table>
			<rich:panel id="filtroPanel"
				style="width:690px;margin-right: 5px; margin-left: 2px;">
				<f:facet name="header">
					<h:outputText value="Filtro de Busqueda" />
				</f:facet>

				<rich:toolBar height="20" id="tbx" width="100%">
					<a4j:commandButton id="botonAplicarFiltro"
						title="Aplicar Filtro de Busqueda" image="/imagenes/document.png" 
						reRender="fitroPanel" actionListener="#{backingBean[aplicarFiltroEvent]}" />
					<a4j:commandButton id="botonCerrarFiltro" onclick="ocultarFiltro()" immediate="true"
						title="Cerrar panel de  Filtro de Busqueda" 
						image="/imagenes/error.gif" />
				</rich:toolBar>
			</rich:panel>
		</a4j:region>
		<br/>
	</ui:composition>

</html>